package pres.liko.blackapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pres.liko.blackapi.pojo.Dc3BlackApi;
import pres.liko.blackapi.service.BlackApiService;
import pres.liko.iot.bean.R;
import reactor.core.publisher.Mono;

import java.util.Set;

/**
 * @ClassName: BlackApiController
 * @Auther: liko
 * @Description:
 * @Date: 2022/11/2 21:46
 */
@RestController
@RequestMapping("/blackapi")
public class BlackApiController {

    private BlackApiService blackApiService;

    @Autowired
    public BlackApiController(BlackApiService blackApiService) {
        this.blackApiService = blackApiService;
    }

    @PostMapping("/api")
    public Mono<R<Object>> addApi(@RequestBody Mono<Dc3BlackApi> blackApiMono) {
        return blackApiService.addApi(blackApiMono);
    }

    @GetMapping("/api")
    public Mono<R<Set<String>>> findAllEnable() {
        return blackApiService.findAllEnable();
    }

    @PutMapping("/api/{id}/{deleted}")
    public Mono<R<Object>> upenabledateEnableById(@PathVariable String id, @PathVariable String deleted) {
        return blackApiService.updateEnableById(id, deleted);
    }

    @DeleteMapping("/api/{id}")
    public Mono<R<Object>> deleteById(@PathVariable String id) {
        return blackApiService.deleteById(id);
    }
}
